﻿define(function (require) {
    require('models/project');
    var service = require('utility/service');
    
    var ProjectStatusValue = {
        Ongoing: 1,
        Archived: 2
    };
    
    window.ProjectList = Backbone.Collection.extend({
        model: Project,
        comparator: function (e) {
            return e.get('StatusValue');
        },
        initialize: function () {
            this.getAll();
        },
        getAll: function () {
            var _self = this;
            service.GetAllFullProjects(function (projectList) {
                projects = _.select(projectList, function (project) {
                    return project.StatusValue != ProjectStatusValue.Archived;
                });

                _self.add(projects);
                _self.trigger("getAll");
    
            })
          
        }
    });
});